home *** CD-ROM | disk | FTP | other *** search
- class MovingEnemy extends Enemy
- {
- var targetCoords;
- var mc;
- var tm;
- static var SCORE = 150;
- static var SPEED = 2;
- static var ACCEL = 0.30000000000000004;
- static var WAIT_TIME = 60;
- static var ENEMY_TYPE = "enemy2";
- static var MAX_HEALTH = 3;
- static var SHAPE_FLAG = false;
- static var COLOR = 65535;
- var xspeed = 0;
- var yspeed = 0;
- var skipSwitch = 0;
- function MovingEnemy(x, y)
- {
- super(x,y);
- }
- function getScore()
- {
- return MovingEnemy.SCORE;
- }
- function getSpeed()
- {
- return MovingEnemy.SPEED;
- }
- function getEnemyType()
- {
- return MovingEnemy.ENEMY_TYPE;
- }
- function getWaitTime()
- {
- return MovingEnemy.WAIT_TIME;
- }
- function getMaxHealth()
- {
- return MovingEnemy.MAX_HEALTH;
- }
- function getAccel()
- {
- return MovingEnemy.ACCEL;
- }
- function getColor()
- {
- return MovingEnemy.COLOR;
- }
- function getShapeFlag()
- {
- return MovingEnemy.SHAPE_FLAG;
- }
- function move()
- {
- if(this.skipSwitch % 3 == 0)
- {
- var _loc4_ = undefined;
- _loc4_ = Math.atan2(this.targetCoords.y - this.mc._y,this.targetCoords.x - this.mc._x);
- var _loc2_ = this.xspeed * this.xspeed + this.yspeed * this.yspeed;
- var _loc3_ = this.getSpeed() * this.getSpeed();
- this.xspeed += this.getAccel() * Math.cos(_loc4_);
- this.yspeed += this.getAccel() * Math.sin(_loc4_);
- if(_loc2_ > _loc3_)
- {
- this.xspeed *= _loc3_ / _loc2_;
- this.yspeed *= _loc3_ / _loc2_;
- }
- this.mc._rotation = CustomMath.radToDeg(Math.atan2(this.yspeed,this.xspeed));
- }
- this.skipSwitch = this.skipSwitch + 1;
- this.mc._x += this.xspeed;
- this.mc._y += this.yspeed;
- this.tm.makeTrail();
- }
- function step()
- {
- if(this.checkProximity())
- {
- this.assignNewTarget();
- }
- else
- {
- this.move();
- }
- this.shootIfAble();
- this.checkHit();
- }
- function getWeaponsPoints()
- {
- var _loc2_ = new flash.geom.Point(this.mc.turret.weapon1._x,this.mc.turret.weapon1._y);
- this.mc.turret.localToGlobal(_loc2_);
- return new Array(_loc2_);
- }
- function rotateToPlayer()
- {
- var _loc3_ = Math.atan2(_root.player.getMovie()._y - this.mc._y,_root.player.getMovie()._x - this.mc._x);
- this.mc.turret._rotation = CustomMath.radToDeg(_loc3_) - this.mc._rotation;
- }
- }
-